/*******************************************************************************
*
*   FILE NAME:
*       GraphicsDevice.h - GraphicsDevice class definition
*
*   DESCRIPTION:
*       Performs primitive-based rendering, creates resources, handles
*       system-level variables, adjusts gamma ramp levels, and creates shaders.
*
*******************************************************************************/
#pragma once

#include "Color.h"
#include "DisplayMode.h"
#include "GraphicsAdapter.h"
#include "PresentationParameters.h"
#include "RenderTarget2D.h"
#include "Types.h"
#include "Viewport.h"

#include <d3d11.h>
#pragma comment ( lib, "d3d11.lib" )

class RenderTarget2D;

class GraphicsDevice
{
public:
    GraphicsDevice( GraphicsAdapter& graphics_adapter, const PresentationParameters& presentation_parameters );
    ~GraphicsDevice( void );

    void Clear( const Color& color );
    void Present( void );

    void Reset( void );
    void Reset( const PresentationParameters& presentation_parameters );
    void Reset( const PresentationParameters& presentation_parameters, GraphicsAdapter& graphics_adapter );

    PresentationParameters GetPresentationParameters( void );
    Viewport GetViewport( void );

    void SetRenderTarget( const RenderTarget2D* render_target );
    void SetViewport( const Viewport& viewport );

protected:

private:
    RenderTarget2D*         mBackBuffer;
    DisplayMode             mDisplayMode;
    GraphicsAdapter&        mGraphicsAdapter;
    PresentationParameters  mPresentationParameters;
    RenderTarget2D*         mRenderTarget;
    Viewport                mViewport;

    friend class RenderTarget2D;
    IDXGISwapChain*         mSwapChain;
    ID3D11Device*           mDevice;
    ID3D11DeviceContext*    mDeviceContext;

    GraphicsDevice( const GraphicsDevice& other );
    GraphicsDevice& operator=( const GraphicsDevice& other );
};
